package com.oa.service.impl;

import java.util.List;




import javax.annotation.Resource;

import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.oa.dao.ForumDao;
import com.oa.entity.Forum;
import com.oa.service.ForumService;

@Service("forumService")
@Transactional
public class ForumServiceImpl implements ForumService {
	
	//通过注解把发帖Dao注入进来
    @Resource(name="forumDao")
    private ForumDao forumDao;

	

	public List<Forum> selectAllForum() {
		List<Forum> forumList = forumDao.queryAllForum();
		return forumList;
	}

	public Forum seleteForum(String forumId) {
		Forum forum = forumDao.loadEntity(forumId);
		return forum;
	}

	public ForumDao getForumDao() {
		return forumDao;
	}

	public void setForumDao(ForumDao forumDao) {
		this.forumDao = forumDao;
	}

	public boolean addForum(Forum forum) {
		
		forum.setTopicCount(0);
		forum.setArticleCount(0);
		forum.setLastTopic(null);
		return forumDao.saveEntity(forum);
	}

	public boolean updateForum(Forum forum) {
		return forumDao.updateEntity(forum);
	}

	public boolean deleteForum(Forum forum) {
		return forumDao.deleteEntity(forum);
	}
   
	
}
